package com.esri.core.internal.tasks.ags;

import com.esri.core.geometry.SpatialReference;
import com.esri.core.map.Feature;
import java.util.LinkedHashMap;
import java.util.Map;

/* loaded from: classes.dex */
public class i extends com.esri.core.internal.tasks.f {
    private static final long serialVersionUID = 1;
    public Feature[] a;
    public long[] b;
    public Feature[] c;
    SpatialReference d;
    public boolean e = true;
    private String f = null;

    @Override // com.esri.core.internal.tasks.f
    public boolean validate() {
        return true;
    }

    public SpatialReference a() {
        return this.d;
    }

    public void a(SpatialReference spatialReference) {
        this.d = spatialReference;
    }

    public String b() {
        return this.f;
    }

    public void a(String str) {
        this.f = str;
    }

    @Override // com.esri.core.internal.tasks.f
    public Map<String, String> generateRequestParams() throws Exception {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("f", "json");
        Feature[] featureArr = this.a;
        if (featureArr != null) {
            linkedHashMap.put("adds", a(featureArr, true));
        }
        long[] jArr = this.b;
        if (jArr != null) {
            linkedHashMap.put("deletes", a(jArr));
        }
        Feature[] featureArr2 = this.c;
        if (featureArr2 != null) {
            linkedHashMap.put("updates", a(featureArr2, this.e));
        }
        String str = this.f;
        if (str != null) {
            linkedHashMap.put("gdbVersion", str);
        }
        return linkedHashMap;
    }

    String a(Feature[] featureArr, boolean z) throws Exception {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        boolean z2 = true;
        for (Feature feature : featureArr) {
            if (feature != null) {
                if (z2) {
                    String a = com.esri.core.internal.util.d.a(feature, this.d, z);
                    if (a != null) {
                        sb.append(a);
                        z2 = false;
                    }
                } else {
                    String a2 = com.esri.core.internal.util.d.a(feature, this.d, z);
                    if (a2 != null) {
                        sb.append(',');
                        sb.append(a2);
                    }
                }
            }
        }
        sb.append(']');
        return sb.toString();
    }

    String a(long[] jArr) throws Exception {
        StringBuilder sb = new StringBuilder();
        boolean z = true;
        for (long j : jArr) {
            if (j >= 0) {
                if (z) {
                    sb.append(j);
                    z = false;
                } else {
                    sb.append(',');
                    sb.append(j);
                }
            }
        }
        return sb.toString();
    }
}
